package com.yunji.cabinet.service.impl;

import com.yunji.cabinet.dao.IContainerCycleDao;
import com.yunji.cabinet.domain.CabinetCycleDO;
import com.yunji.cabinet.dto.CabinetCycleDTO;
import com.yunji.cabinet.vo.CabinetCycleVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author : peter-zhu
 * @date : 2024/10/31 19:19
 * @description : TODO
 **/
@Service
public class ContainerCycleService {
    @Resource
    private IContainerCycleDao containerCycleDao;

    public List<CabinetCycleVO> cyclePageList(CabinetCycleDTO dto) {
        List<CabinetCycleDO> list = containerCycleDao.cyclePageList(dto);
        List<CabinetCycleVO> voList = new ArrayList<CabinetCycleVO>();
        for (CabinetCycleDO cycleDO : list) {
            CabinetCycleVO vo = new CabinetCycleVO();
            BeanUtils.copyProperties(cycleDO, vo);
            //Date endTime = cycleDO.getEndTime() == null ? new Date() : cycleDO.getEndTime();
            //vo.setEndTime(endTime);
            voList.add(vo);
//            Date startTime = cycleDO.getStartTime();
//            Date endTime = cycleDO.getEndTime() == null ? new Date() : cycleDO.getEndTime();
//            Map<String, String> map = TimeUtils.timeToMap(startTime, endTime);
//            cycleDO.setEndTime(cycleDO.getEndTime() == null ? new Date() : cycleDO.getEndTime());
        }
        return voList;
    }


}
